package com.hk.commons.poi.excel.write.handler;

import com.hk.commons.poi.excel.metadata.WriteWorkbook;
import org.apache.poi.ss.usermodel.Workbook;

import java.io.OutputStream;
import java.util.Collections;


/**
 * @author Kevin
 */
public interface WriteableHandler {

    /**
     * 写数据到 workbook
     *
     * @param workbook  workbook
     * @param sheetBook sheetBook
     * @param out       out
     */
    default void write(Workbook workbook, WriteWorkbook sheetBook, OutputStream out) {
        write(workbook, Collections.singletonList(sheetBook), out);
    }

    /**
     * 写数据到 workbook，支持多个 sheet
     *
     * @param workbook   workbook
     * @param sheetBooks sheetBooks，每个sheet的参数
     * @param out        out
     */
    void write(Workbook workbook, Iterable<WriteWorkbook> sheetBooks, OutputStream out);
}
